package com.prg.model.base;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;

/**
 * AuthPermission entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "AUTH_PERMISSION", schema = "SSHE")
public class AuthPermission implements java.io.Serializable {

	// Fields

	private String id;
	private String name;
	private String contentTypeId;
	private String codename;
	private Set<AuthGroup> authGroups = new HashSet<AuthGroup>(0);

	// Constructors

	/** default constructor */
	public AuthPermission() {
	}

	/** full constructor */
	public AuthPermission(String name, String contentTypeId, String codename,
			Set<AuthGroup> authGroups) {
		this.name = name;
		this.contentTypeId = contentTypeId;
		this.codename = codename;
		this.authGroups = authGroups;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "ID", unique = true, nullable = false, length = 100)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "NAME", length = 100)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "CONTENT_TYPE_ID", length = 100)
	public String getContentTypeId() {
		return this.contentTypeId;
	}

	public void setContentTypeId(String contentTypeId) {
		this.contentTypeId = contentTypeId;
	}

	@Column(name = "CODENAME", length = 100)
	public String getCodename() {
		return this.codename;
	}

	public void setCodename(String codename) {
		this.codename = codename;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "AUTH_GROUP_PERMISSION", schema = "SSHE", joinColumns = { @JoinColumn(name = "PERMISSION_ID", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "GROUP_ID", updatable = false) })
	public Set<AuthGroup> getAuthGroups() {
		return this.authGroups;
	}

	public void setAuthGroups(Set<AuthGroup> authGroups) {
		this.authGroups = authGroups;
	}

}